package com.job.liushuang.HomeWork0714;

import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;

/**
 * @author Liushuang
 * @version 1.0
 * @since 2022-07-14 20:20:28
 */
public class UseBig {
    public static void main(String[] args) {
        double d1=2.0,d2=1.1;
        System.out.println(d1-d2);

        BigDecimal b1=new BigDecimal("20.123456789123456789123456789");
        //大数字不能使用普通的算术运算，需要使用方法
        BigDecimal b2=new BigDecimal("2.123456789123456789123456789123456789123456789");

        BigDecimal result=b1.divide(b2, 30, RoundingMode.HALF_UP);

        System.out.println(result.toString());

        BigDecimal b3=new BigDecimal(3.14);

        BigDecimal multiply=b1.multiply(b3,new MathContext(30,RoundingMode.HALF_UP));
        System.out.println(multiply);

        BigDecimal multiply2=b1.multiply(b3);
        multiply2=multiply2.setScale(30, RoundingMode.HALF_UP);
        System.out.println(multiply2);
    }
}
